//
//  EkoButton.swift
//  doubandiantai
//
//  Created by 王海申 on 2017/8/3.
//  Copyright © 2017年 王海申. All rights reserved.
//

import UIKit

class EkoButton: UIButton {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    
    var isplay:Bool = true;
    
    let imagePlay:UIImage = UIImage(named:"play")!
    let imagePause:UIImage = UIImage(named:"pause")!
    
    
    required init(coder aDecoder:NSCoder){
        
        super.init(coder:aDecoder)!
        
        self.addTarget(self, action: #selector(EkoButton.onClick), for: UIControlEvents.touchUpInside)
        
    }
    
    
    func onClick(){
        isplay = !isplay;
        
        
        
        if isplay{
            
            
            self.setImage(imagePause, for: UIControlState.normal)
        }else{
            
             self.setImage(imagePlay, for: UIControlState.normal)
            
        }
        
        
        
        
    }
    
    
    func play(){
        isplay = true;
        self.setImage(imagePause, for: UIControlState.normal)

        
    }
    

}
